From: Jo-Philipp Wich Date: Wed, 2 Nov 2022 08:04:25 +0000 (+0100) Subject: luci-base: http.uc: fix invoking Lua file upload callbacks X-Git-Url: http://git.openwrt.org/%22https:/collectd.org//%22/%22https:/collectd.org/%22?a=commitdiff_plain;h=d967bbaa92ae56692ab449f57ca74f120943e799;p=project%2Fluci.git luci-base: http.uc: fix invoking Lua file upload callbacks In case a callback is installed from Lua code, the received callback argument is not a callable function but a resource object with a call method. Attempts to call it will leading to a `Type error: left-hand side is not a function` error. To solve this issue, invoke the internally set filehandler instead which wraps the resource if needed. Fixes: #6067 Signed-off-by: Jo-Philipp Wich --- diff --git a/modules/luci-base/ucode/http.uc b/modules/luci-base/ucode/http.uc index b464497eac..4856c47a0d 100644 --- a/modules/luci-base/ucode/http.uc +++ b/modules/luci-base/ucode/http.uc @@ -432,7 +432,7 @@ const Class = { let data = value.fd.read(1024); let eof = (data == null || data == ''); - callback(value, data, eof); + this.filehandler(value, data, eof); if (eof) { value.fd.close();